import { ref , onMounted } from "vue";

/*
*
* Vue3计算剩余高度
*
*/
export default function () {

    //在Init的时候先行调用，然后在监听窗口的变化，保证是最新的宽高度
    onMounted(()=>{
        setWindowResize();
        window.addEventListener('resize',setWindowResize)
    });

    //测算基点
    let basePoint = ref();

    //元素测试盒子
    let elementToTopHight = ref(0);

    //窗口的高度
    let windowHeight = ref(0);


    const setWindowResize = function () {
        if(!basePoint.value) {return}
        elementToTopHight.value = basePoint.value.getBoundingClientRect().top;
        windowHeight.value = window.innerHeight;
    }


    return { basePoint , elementToTopHight , windowHeight };
}
